package com.dmall.rpc.registry;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

public class ServiceDiscover {

    public String discover() {
        Properties properties = new Properties();
        InputStream in = null;
        try {
            URL url = this.getClass().getClassLoader().getResource("registry.properties");
            in = new FileInputStream(new File(url.getFile()));
            properties.load(in);
            return properties.getProperty("server.address");
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
